// pages/operat/codeRelation/codeRelation.js
var LApp = getApp();
import _global from "../../../source/js/global"
Page({

  /**
   * 页面的初始数据
   */
  data: {
    CodeRelatList:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.data.CodeRelatList = new Array();
    this.getCurrentCodeRelationList();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
   
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    this.setData({
      open: -1
    })
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.CodeRelatList = new Array();
    this.getCurrentCodeRelationList();
    wx.stopPullDownRefresh();
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    this.getCurrentCodeRelationList(this.data.PageIndex += 1);
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  },
  singleRelation: function () {
   wx.scanCode({
     success:(res)=>{
       if (res){
         wx.navigateTo({
           url: 'manyRelation/manyRelation?code=' + res.result,
         })
       }
     }
   })
  },
  manyRelation: function () {
    LApp.openView("manyRelation/manyRelation");
  },
  relationEdit: function () {
    LApp.openView("relationEdit/relationEdit");
  },
  codeDetail: function () {
    wx.showToast({
      icon: 'none',
      title: '攻城狮正在攻城中，稍等~',
    })
    //LApp.openView("codeDetail/codeDetail");
  },
  getCurrentCodeRelationList:function(pageindex){
    this.data.PageIndex = pageindex||1;
    var _this = this;
    LApp._get({
      url:'nbapi/codemanager/code/relation/page/list',
      data:{pageIndex:this.data.PageIndex,pageSize:15},
      success:function(r){
        _this.setData({
          CodeRelatList: _this.data.CodeRelatList.appendArray(r)          
        })
      }
    })
  },
  /**
  * 右滑操作 Begin
 */
  touchMove: _global.Tap_Dray,
  tap_end: _global.Tap_End,
})